import 'dart:io';
import 'package:dio/dio.dart';
import 'package:path_provider/path_provider.dart';


class ZJDownloadSource {

  static final Dio _dio = Dio();

  /// 下载资源
  static Future<String?> downloadSource() async{
    final Directory tempDir = await getApplicationSupportDirectory();
    String path = '${tempDir.path}/live_source.json';
    Response response = await _dio.download("https://zhangjiang1203.github.io/iptvsource/live_source.json", path);
    if(response.statusCode == 200){
      /// 请求成功 使用网络数据
      File jsonFile = File(path);
      String jsonStr = await jsonFile.readAsString();
      return jsonStr;
    }
  }
}